﻿<%@ Page Language="C#" MasterPageFile="~/DefaultMaster.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Pariveda.ObjectDataSource.Web.Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
    #CategoryDiv
    {
    	float: left;
    	margin-right: 24px;
    }
    #GridDiv
    {
    	margin-top: 24px;
    }
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="CategoryDiv">
    <div class="Label">Category:</div>
    <asp:DropDownList ID="CategoryDropDownList" runat="server" 
        AutoPostBack="true"
        DataSourceID="CategoryObjectDataSource" DataTextField="Value" 
        AppendDataBoundItems="true"
        DataValueField="Key">
        <asp:ListItem Value="-1" Text="- All Categories -"/>
    </asp:DropDownList>
    <asp:ObjectDataSource ID="CategoryObjectDataSource" runat="server" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetList" 
        TypeName="Pariveda.ObjectDataSource.Business.CategoryController">
    </asp:ObjectDataSource>
    </div>
    <div id="SupplierDiv">
    <div class="Label">Supplier:</div>
    <asp:DropDownList ID="SupplierDropDownList" runat="server" 
        AutoPostBack="true"
        DataSourceID="SupplierObjectDataSource" DataTextField="Value" 
        AppendDataBoundItems="true"
        DataValueField="Key">
            <asp:ListItem Value="-1" Text="- All Suppliers -" />
    </asp:DropDownList>
    <asp:ObjectDataSource ID="SupplierObjectDataSource" runat="server" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetList" 
        TypeName="Pariveda.ObjectDataSource.Business.SupplierController">
    </asp:ObjectDataSource>
    
    </div>
    <asp:UpdatePanel ID="GridUpdatePanel" runat="server" UpdateMode="Conditional">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="CategoryDropDownList" EventName="SelectedIndexChanged" />
            <asp:AsyncPostBackTrigger ControlID="SupplierDropDownList" EventName="SelectedIndexChanged" />
        </Triggers>
        <ContentTemplate>
            <div id="GridDiv">
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" EnableSortingAndPagingCallbacks="True" AllowSorting="true"
                Width="600px"
                AutoGenerateColumns="False" DataSourceID="ProductObjectSource">
                <Columns>
                    <asp:BoundField DataField="ProductName" HeaderText="Product" 
                        SortExpression="ProductName" ItemStyle-Width="250px" HeaderStyle-HorizontalAlign="Left" />
                    <asp:BoundField DataField="CategoryName" HeaderText="Category" 
                        SortExpression="CategoryName" ItemStyle-Width="100px" HeaderStyle-HorizontalAlign="Left" />
                    <asp:BoundField DataField="SupplierName" HeaderText="Supplier" 
                        SortExpression="SupplierName" ItemStyle-Width="250px" HeaderStyle-HorizontalAlign="Left"/>
                </Columns>
                <EmptyDataTemplate>
                    No results match this critieria
                </EmptyDataTemplate>
            </asp:GridView>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:ObjectDataSource ID="ProductObjectSource" runat="server" 
        EnablePaging="True" OldValuesParameterFormatString="original_{0}" 
        SelectCountMethod="GetListCount" SelectMethod="GetList"  SortParameterName="sortType" 
        TypeName="Pariveda.ObjectDataSource.Business.ProductController">
        <SelectParameters>
            <asp:ControlParameter ControlID="CategoryDropDownList" 
                DefaultValue="null" Name="categoryId" PropertyName="SelectedValue" 
                Type="Int32" />
            <asp:ControlParameter ControlID="SupplierDropDownList" 
                DefaultValue="null" Name="supplierId" PropertyName="SelectedValue" 
                Type="Int32" />        
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>
